class S2.FX.Heartbeat
Description
The heartbeat class provides for effects timing. An instance of this class is automatically created when the first effect on a page is instantiated.
This class can be extended and replaced by your own implementation:
// call before effects are created
var myHeartbeat = Class.create(S2.FX.Heartbeat, { ... });
S2.FX.initialize(new myHeartbeat());
This can be used to implement customized debugging and more.
Constructor
new S2.FX.Heartbeat([options])
-
options(Object) – options hash
The following options are available: * framerate: set (maximum) framerate for calls to S2.FX.beat/
Instance methods
-
beat #
S2.FX.Heartbeat#beat() -> undefinedThis method fires an
effect:heartbeatevent which is in turn used byS2.FXto render all active effect queues.Fires: effect:heartbeat
-
generateTimestamp #
S2.FX.Heartbeat#generateTimestamp() -> DateReturns the current date and time.
-
getTimestamp #
S2.FX.Heartbeat#getTimestamp() -> DateReturns the current timestamp.
-
start #
S2.FX.Heartbeat#start() -> undefinedThis function is called by
S2.FXwhenever there's a new active effect queued and there are no other effects running. This mechanism can be used to prevent unnecessary timeouts/intervals from being active, as S2.FX.Hearbeat.beat is only called when there are active effects that need to be rendered. -
stop #
S2.FX.Heartbeat#stop() -> undefinedCalled when the last active effect is dequeued.
-
updateTimestamp #
S2.FX.Heartbeat#updateTimestamp() -> undefinedUpdates the current timestamp (sets it to the current date and time).
If subclassed, this can be used to achieve special effects, for example all effects could be sped up or slowed down.